﻿using System.Data.Common;
using System.Diagnostics;
using System.Security.Cryptography.Xml;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using HandyControl.Controls;
using HandyControl.Data;
using 多协议通信平台.Common;
using MessageBox = HandyControl.Controls.MessageBox;
using Window = System.Windows.Window;

namespace 多协议通信平台.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainView : Window
    {
        public MainView()
        {
            InitializeComponent();
        }

        private void Min_Size_Click(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState.Minimized;
        }

        private void Close_Btn_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show(new MessageBoxInfo()
            {
                Message = "请确认是否要关闭系统！",
                Caption = "提示",
                Icon = Geometry.Parse("M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"),
                Button = MessageBoxButton.YesNo,
            });
            if (result == MessageBoxResult.Yes)
                Application.Current.Shutdown(0);
        }

        private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }


        private void Menu_Size_Change_Click(object sender, RoutedEventArgs e)
        {
            bool collapsed = lft_grid.Width.Value == 230;
            
            GridLength targetWidth = collapsed ? new GridLength(60) : new GridLength(230);

            GridLengthAnimation animation = new GridLengthAnimation
            {
                From = lft_grid.Width,
                To = targetWidth,
                Duration = TimeSpan.FromSeconds(0.3),
                EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
            };

            lft_grid.BeginAnimation(ColumnDefinition.WidthProperty, animation);
        }

        private void Max_Size_Click(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState.Maximized == WindowState ? WindowState.Normal : WindowState.Maximized;
        }
    }
}